Skip to content

Comments

FLPATH-2749 | Refactor the Plugin code based on new structure to cost-management#2341

Open
asmasarw wants to merge 3 commits intoredhat-developer:mainfrom
asmasarw:feature/cost-m
Open

FLPATH-2749 | Refactor the Plugin code based on new structure to cost-management#2341
asmasarw wants to merge 3 commits intoredhat-developer:mainfrom
asmasarw:feature/cost-m

Conversation

@asmasarw
Copy link
Contributor

@asmasarw asmasarw commented Feb 17, 2026

FLPATH-2749 | Refactor the Plugin code based on new structure to cost-management

@rhdh-gh-app
Copy link

rhdh-gh-app bot commented Feb 17, 2026

Missing Changesets

The following package(s) are changed by this PR but do not have a changeset:

  • @red-hat-developer-hub/plugin-cost-management-common
  • @red-hat-developer-hub/plugin-cost-management

See CONTRIBUTING.md for more information about how to add changesets.

Changed Packages

Package Name Package Path Changeset Bump Current Version
app workspaces/cost-management/packages/app none v0.0.5
backend workspaces/cost-management/packages/backend none v0.0.5
@red-hat-developer-hub/plugin-cost-management-backend workspaces/cost-management/plugins/cost-management-backend patch v2.0.2
@red-hat-developer-hub/plugin-cost-management-common workspaces/cost-management/plugins/cost-management-common none v2.0.1
@red-hat-developer-hub/plugin-cost-management workspaces/cost-management/plugins/cost-management none v2.0.1

@asmasarw asmasarw changed the title Modify Yaml files FLPATH-2749 | Refactor the Plugin code based on new structure to cost-management Feb 17, 2026
@asmasarw asmasarw requested review from a team as code owners February 17, 2026 10:46
Copy link
Member

@alizard0 alizard0 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left some comments.

credentials: dangerously-allow-unauthenticated
resourceOptimization:
costManagement:
clientId: ${ROS_CLIENT_ID}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@asmasarw if it is called costManagement, why do we still have env variables with ROS_ shouldn't it be refactored too?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

agree,
changed to CM_

const baseUrl =
configApi.getOptionalString('costManagementProxyBaseUrl') ??
configApi.getOptionalString(
'costManagement.costManagementProxyBaseUrl',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@asmasarw this seem to be a breaking change, you added a prefix.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was done by mistake, Reverted.
Thanks

'costManagement.costManagementProxyBaseUrl',
) ??
configApi.getOptionalString(
'costManagement.optimizationsBaseUrl',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@asmasarw here too, the prefix was added not refactored.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was done by mistake, Reverted.
Thanks

@@ -15,7 +15,7 @@
*/

export interface Config {
resourceOptimization: {
costManagement: {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As I commented before, previously this was used without prefix, and after the refactor you introduced a prefix, is thsi expect? is this the config?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here the name is fine, but the nested values were incorrect.
Reverted.

* Override generated pluginId so discovery matches the backend plugin ID
* (OpenAPI info.title is set to 'cost-management' for the API name).
*/
setPluginIdValue(pluginIdFilePath, value) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need this? If this is a refactoring PR, why do we have new code. I don't understand why is this relevant and previously wasnt.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was done by mistake, Reverted.
Thanks

console.log('Setting pluginId to backend plugin ID for discovery');
tsSourceFileMutator.setPluginIdValue(
`${commonPackageDir}/src/generated/pluginId.ts`,
'redhat-resource-optimization',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

redhat-resource-optimization?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was done by mistake, Reverted.

@@ -120,7 +120,7 @@ export const getLegendData = (

const result: any = [];

series.map((s, index) => {
series.forEach((s, index) => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is that?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a Sonar Qube Issue fixed here.
CI fail here, unless we're changing the map to forEach.

@asmasarw asmasarw enabled auto-merge (squash) February 23, 2026 12:17
@asmasarw asmasarw disabled auto-merge February 23, 2026 12:56
@@ -2,23 +2,23 @@
"packageRules": [
{
"description": "all Redhat Resource Optimization minor updates",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Update this to Red hat Cost Management instead of Resource Optimization

Copy link
Member

@alizard0 alizard0 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please review the .github/renovate-presets/workspace/rhdh-redhat-resource-optimization-presets.json‎ file. I found multiple entries for Resource Optimization and I think you are renaming to Cost Management no?

"matchFileNames": ["workspaces/redhat-resource-optimization/**"],
"matchFileNames": ["workspaces/cost-management/**"],
"extends": [
"github>redhat-developer/rhdh-plugins//.github/renovate-presets/base/rhdh-patch-presets(RH Resource Optimization)"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same applies here, if i am not wrong. Cost Management is the new name for it, right?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Renamed, But It fails on:
Renovate Config Validator - as I understand it's because it tries to search for the preset in the upstream, but since we are renaming this, it doesn't exist yet in the Upstream branch.

Once merged this CI validation will pass.

Copy link
Contributor

@PreetiW PreetiW left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Incomplete Plugin Rename — redhat-resource-optimizationcost-management

The workspace directory was renamed to cost-management/, but the plugins, packages, IDs, routes, configs, and scripts all still use redhat-resource-optimization. This needs to be completed for the dynamic plugin image to build and install correctly under the new name.

What's done ✅

  • Workspace directory: workspaces/cost-management/
  • repository.directory fields in all package.json files
  • README title uses "Cost Management"
  • OpenAPI spec title uses cost-management
  • Parent menu item in dynamic-plugins.yaml uses cost-management

What's still using the old name ❌

1. Plugin directories

  • plugins/redhat-resource-optimization/plugins/cost-management/
  • plugins/redhat-resource-optimization-backend/plugins/cost-management-backend/
  • plugins/redhat-resource-optimization-common/plugins/cost-management-common/

2. NPM package names (all package.json)

  • @internal/redhat-resource-optimization@internal/cost-management
  • @red-hat-developer-hub/plugin-redhat-resource-optimization@red-hat-developer-hub/plugin-cost-management
  • @red-hat-developer-hub/plugin-redhat-resource-optimization-backend@red-hat-developer-hub/plugin-cost-management-backend
  • @red-hat-developer-hub/plugin-redhat-resource-optimization-common@red-hat-developer-hub/plugin-cost-management-common
  • All backstage.pluginId, backstage.pluginPackages, and workspace dependencies need updating

3. Plugin IDs in source

  • plugins/.../src/plugin.ts (FE): id: 'redhat-resource-optimization'
  • plugins/.../src/plugin.ts (BE): pluginId: 'redhat-resource-optimization'
  • plugins/.../src/generated/pluginId.ts: pluginId = 'redhat-resource-optimization'
  • plugins/.../src/apis.ts: id: 'plugin.redhat-resource-optimization.api'

4. Route paths

update the route paths as well to /cost-management

5. Dynamic plugin config

  • dynamic-plugins.yaml: package path, plugin key, menu item keys (redhat-resource-optimization, redhat-resource-optimization.ocp)
  • app-config.dynamic.yaml (FE + BE): plugin keys
  • Note: importName values (ResourceOptimizationPage, OpenShiftPage, ResourceOptimizationIcon) should stay as-is — they are code export names describing the feature.

6. Config & metadata

  • app-config.yaml: app.title: Red Hat - Resource Optimization
  • catalog-info.yaml: metadata.name and metadata.title
  • vs.code-workspace: window.title

7. scripts/dynamic-plugins.sh

update the reference and regenerate the image, check if image gets generated correctly and used correctly

8. Common lib internals

  • scripts/lib/openapi.mjs: spec.info.title
  • scripts/generate_client.mjs: DEFAULT_PLUGIN_DIRECTORY
  • src/clients/optimizations/types.ts: comment reference

9. Root package.json scripts

  • start:fe-plugin and start:be-plugin workspace references

10. Documentation

  • Plugin READMEs: npm package names, route paths, endpoint references
  • docs/dynamic-plugin.md: any old name references

Post-rename tasks

  1. Regenerate yarn.lock (yarn install)
  2. Regenerate API reports (yarn build:api-reports)
  3. Test dynamic plugin build (scripts/dynamic-plugins.sh oci)
  4. Update .github/renovate-presets/workspace/rhdh-redhat-resource-optimization-presets.json

@asmasarw once you update the above let me know and I will test and review again 🙌🏻

{
"description": "all Redhat Resource Optimization dev dependency updates",
"matchFileNames": ["workspaces/redhat-resource-optimization/**"],
"matchFileNames": ["workspaces/cost-management/**"],
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@asmasarw can we rename this file as well please to avoid confusion?

@sonarqubecloud
Copy link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants